package com.zzl.boot.bigevent.mapper;

import com.zzl.boot.bigevent.pojo.category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface categoryMapper {

    @Select("insert into category(category_name,create_time,update_time)" +
            "values (#{categoryName},now(),now())")
    void addCategory( category category);

    @Select("select * from category")
    List<category> getAllCategory();

    @Select("select * " +
            "from category" +
            " where id=#{id}")
    category getCategoryDetail(Integer id);

    @Select("update category set category_name=#{categoryName}," +
            "update_time=now()" +
            "where id=#{id}")
    void updateCategory(category category);

    @Select("delete from category where id=#{id}")
    void delById(Integer id);

    @Select("select count(*) from article where category_id= #{id}")
    int artilceCount(Integer id);
}
